/*
 * @Date: 2021-09-10 09:58:54
 * @Author: Acckno1
 * @LastEditTime: 2021-09-10 10:19:01
 * @Description: 
 */
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int n, m;
unordered_map<int, unordered_set<int>> mp;

/**
 * @description: ⽤map存储每⼀个货物的所有不兼容货物～在判断给出的⼀堆货物是否是相容的时候，判断任
⼀货物的不兼容货物是否在这堆货物中～如果存在不兼容的货物，则这堆货物不能相容～如果遍历完
所有的货物，都找不到不兼容的两个货物，则这堆货物就是兼容的～
 * @param {*}
 * @return {*}
 */
inline void solution() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i ++ ) {
        int a, b;
        scanf("%d%d", &a, &b);
        mp[a].insert(b);
        mp[b].insert(a);
    }
    for (int i = 0; i < m; i ++ ) {
        int cnt;
        unordered_set<int> st;
        scanf("%d", &cnt);
        while (cnt -- ) {
            int a;
            scanf("%d", &a);
            st.insert(a);
        }
        bool flag = true;
        for (auto& s : st) {
            auto ust = mp[s];
            for (auto& t : ust) {
                if (st.count(t)) {
                    flag = false; break;
                }
            }
            if (!flag) break;
        }
        if (flag) printf("Yes\n");
        else printf("No\n");
    }
}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}